<?php
$data = new CSVHandler(DATA_PATH . 'prise-list.csv', ';', 'record');
$priselist = $data->Select('*');
$vars = parse_ini_file(DATA_PATH . 'prise-list.txt');
foreach ($priselist as $id => $record){
	foreach ($record as $column => $value){
		if(!empty($value) && $value{0} == '~'){
			$value = substr($value, 1);
			foreach ($record as $t_column => $t_value){
				$value = str_replace('(!' . $t_column . ')', str_replace(',', '.', $t_value), $value);
			}
			foreach ($vars as $var => $t_value){
				$value = str_replace('(#' . $var . ')', str_replace(',', '.', $t_value), $value);
			}
			eval('$value = ' . $value . ';');
			$priselist[$id][$column] = $value;
		}
	}
}

$columns = array_keys($priselist[0]);
$out = '<table width="100%" cellpadding="2" cellspacing="0" border="1">';
$out .= '<tr>';
foreach ($columns as $column){
	$out .= '<th>' . $column . '</th>';
}
$i = 1;
foreach ($priselist as $record){
	$out .= '<tr>';
	foreach ($record as $value){
		$out .= '<td class="row' . $i . '">' . $value . '</th>';
	}
	$out .= '</tr>';
	$i++;
	if($i == 4) $i = 1;
}
$out .= '</tr>';
$out .= '</table>';
show_window(__('Prise list'), $out);
?>